import { createApp, provide } from 'vue';
import App from './App.vue';
import './assets/global.less';
import components from './components/global';
import Router from './router/index';

import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import zhCn from 'element-plus/es/locale/lang/zh-cn'

import { currentUserfun, provideGlobalState } from './utils/isLogin.js';



// import '@/router/permission.js';

const app = createApp(App)
app.config.productionTip = false


// 添加全局前置导航守卫
Router.beforeEach((to, from, next) => {
  currentUserfun();
  next(); // 确保继续导航
});
app.provide('isLoginweb', provideGlobalState());

// components
for (const i in components) {
  app.component(i, components[i])
}

app.use(Router).use(ElementPlus, {
  locale: zhCn,
}).mount('#app')


